<template>
  <!--1. 容器 -->
  <div ref="right1_container" id="container" style="height: 95%"></div>
</template>
<script>
// 引入折线图构造函数
import { Line } from "@antv/g2plot";
import {get} from "../../../utils/request"
import moment from "moment"

export default {
  data() {
    return {
      dataArr: [
        {
          year:'1997',
          value:8.12
        },
        {
          year:'2000',
          value:9.15
        },
         {
          year:'2003',
          value:10.29
        },
         {
          year:'2006',
          value:12.31
        },
         {
          year:'2009',
          value:14.44
        },
         {
          year:'2012',
          value:14.71
        },
         {
          year:'2015',
          value:15.78
        },
         {
          year:'2018',
          value:17.11
        },
         {
          year:'2021',
          value:19.78
        },
      ],
    };
  },
  created() {

  },
  mounted() {
   this.initChart();
  },
  methods: {
    // initData(){
    //   get("/dashboard/pageQueryTodayData",{
    //     page:1,
    //     pageSize:5,
    //     device_id:1
    //     }).then(res=>{
    //       console.log(res)
    //      res.data.list.forEach(item => {
    //        item.dateTime = moment(item.insert_time).format('hh:mm')
    //      });
    //      this.dataArr=res.data.list
    //      this.initChart();
    //   })
    // },
    initChart() {
      // 创建一个折线图对象
      const line = new Line(this.$refs.right1_container, {
        data:this.dataArr,
        xField: "year",
        yField: "value",
      });
      // 渲染图像
      line.render();
    },
  },
};
</script>

<style scoped>

</style>